package com.generator.code.util;

import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @author guoq.z
 * @date 2021/4/1
 */
public class ColumnToJavaUtils {

    public static String convertFirUpper(String columnName) {
        String upper = WordUtils.capitalizeFully(columnName, new char[]{'_'});
        return upper.replace("_", "");
    }

    public static String convertFirLower(String columnName) {
        String upper = convertFirUpper(columnName);
        return StringUtils.uncapitalize(upper);
    }

    public static void main(String[] args) {
        String str = "t_vegetable_source";
        String noPrefixTableName = str.replaceFirst("t_", "");
        String upper = convertFirUpper(noPrefixTableName);
        System.out.println(upper);

        String lower = convertFirLower(noPrefixTableName);
        System.out.println(lower);
    }
}
